package coroutines.job

import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

class CoroutineTryTest {
}

fun main() {
    runBlocking {
        val job = launch {
            try {
                repeat(100) {
                    delay(500)

                    println("$it in ${Thread.currentThread().name}")
                }
            } catch (t: Throwable) {
                println("error: ${t.message}")
            } finally {
                println("finally")
            }
        }

        delay(2500)

        job.cancel()
    }
}